<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddColumnsToTransferTable extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		$prefix = config('ibrand.app.database.prefix', 'ibrand_');

		Schema::table($prefix . 'store_transfer', function (Blueprint $table) {
            $table->string('type')->default('transfer_out')->after('remark');  // transfer_out:调出，transfer_in：调入

            //如果为调出：out_shop_id：本门店ID， in_shop_id：如果为0，表示调给其他人，否则表示调给其他门店
            //如果为调入,只有可能从其他人调入：out_shop_id=0，表示从其他人调入，in_shop_id=本门店ID

			$table->decimal('total_amount')->default(0);
		});

		Schema::table($prefix . 'store_transfer_item', function (Blueprint $table) {
			$table->decimal('total_amount')->default(0);
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		$prefix = config('ibrand.app.database.prefix', 'ibrand_');

		Schema::table($prefix . 'store_transfer', function (Blueprint $table) {
			$table->dropColumn(['total_amount','type']);
		});

		Schema::table($prefix . 'store_transfer_item', function (Blueprint $table) {
			$table->dropColumn('total_amount');
		});
	}
}
